from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
import time
from time import  sleep
# 创建浏览器驱动对象
driver = webdriver.Chrome()
# 加载web页面
driver.get("http://121.43.169.97:8848/pageA.html")
# 放大浏览器
driver.maximize_window()
# 实体化并获取ActionChains类
action=ActionChains(driver)

# 定位用户名 在用户名上右击鼠标
# username=driver.find_element_by_css_selector("#userA")
# #调用右击方法
# cc=action.context_click(username)
# # 执行
# cc.perform()
# 合并
# action.context_click(driver.find_element_by_css_selector("#userA")).perform()


# 打开注册页面A，输入用户名admin，暂停3秒钟后，双击鼠标左键，选中admin
username2=driver.find_element_by_css_selector("#userA").send_keys("admin")
# 暂停3秒
time.sleep(3)
# 双击鼠标左键，选中admin
dc=action.double_click(username2)
dc.perform()
# 将鼠标移动到”注册按钮“,预期：按钮变红
button=driver.find_element_by_xpath("//p[5]/button")
action.move_to_element(button).perform()
# driver.quit()